<?php

namespace IDock\Insurance\TPBX\Request;

use GuzzleHttp\Psr7\Stream;
use IDock\Http\RequestFormat;
use IDock\IDock\IDockEnums;
use IDock\Insurance\TPBX\Request\AllTPBXRequest;
use IDock\Insurance\TPBX\Response\UploadFileResponse;
use IDock\Insurance\TPBX\TPBXEnums;
use IDock\Visitor\Premium\PremiumInquiryVisitor;
use IDock\Visitor\UploadFileVisitor;
use ZipArchive;

class UploadFileRequest extends AllTPBXRequest
{
    public $requestType = 'file';

    protected $response = UploadFileResponse::class;

    protected $urlTip = '影像上传';
    
    protected $inLog = false;

    /**
     * @var  UploadFileVisitor $visitor
     */
    protected $visitor;

    public function generate(): array
    {
        $row = $this->visitor->getFileList()[0];
        $url = $row['url'] ?? '';
        $extArr = explode('.',basename($url));
        $ext = end($extArr);
        $arr = [
            'fileType' => $ext,
            'Content-Type' => 'application/octet-stream',
            'Charset' => 'utf-8',
            'url' =>$url
        ];
        return $arr;
    }

}
